﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PingPong
{
    class MinuPad 
    {
        public Texture2D myPadTexture;
        public Vector2 myPadPosition;
        public Rectangle myPadRectangle;

        public int myPadWidth;
        public int myPadHeight;

        int screenWidth;
        int screenHeight;

        int myPadSpeed = 3;
        public MinuPad(Texture2D newPadTexture, Vector2 newPadPosition, int newPadWidth, int newPadHeight, int newScreenWidth, int newScreenHeight)
        {
            myPadTexture = newPadTexture;
            myPadPosition = newPadPosition;
            myPadWidth = newPadWidth;
            myPadHeight = newPadHeight;
            screenWidth = newScreenWidth;
            screenHeight = newScreenHeight;

            
            
        }

        public void Draw(SpriteBatch spriteBatch) {

            spriteBatch.Draw(myPadTexture, myPadPosition, myPadRectangle, Color.White);
        }

        public void Update()
        {
            myPadRectangle = new Rectangle((int)myPadPosition.X, (int)myPadPosition.Y, myPadTexture.Width, myPadTexture.Height);
            if ( Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                myPadPosition.X += myPadSpeed;
                if ((myPadPosition.X + myPadTexture.Width) >= screenWidth)
                    myPadPosition.X = (screenWidth-myPadTexture.Width);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                myPadPosition.X -= myPadSpeed;
                if (myPadPosition.X<= 0)
                    myPadPosition.X =0;
            }



        }
    }
}
